Book Contents

How values are rounded

Floating point number is rounded to an integer before it is sent to the connection when an analog tag of the floating point data type is assigned to a:

  • Write connection.
  • Read connection that will be used to trigger a state, alarm, information message, or local message.

When a floating-point value is rounded to an integer:

  • If the number after the decimal is 4 or less, the value is rounded down. For example, 8.495 is rounded to 8.
  • If the number after the decimal is 6 or more, the value is rounded up. For example, 8.6 is rounded to 9.
  • If the number after the decimal is 5, the value is rounded using a "banker’s algorithm," to average out the rounding over time:
    • If the number before the decimal is 0, the value is rounded down. For example, 10.5 is rounded to 10.
    • If the number before the decimal is an odd number, the value is rounded up. For example, 11.5 is rounded to 12.
    • If the number before the decimal is an even number, the value is rounded down. For example, 12.5 is rounded to 12.
    • Floating point values are rounded to a maximum of six digits. Therefore, using a floating-point data type and adding to it a value that exceeds the six significant digits will result in a rounding error. For example, adding any number to 999,999 will result in a rounding error.

      Tip:

      Floating point values (the default values for numeric input objects) are rounded to six digits. Therefore, using a floating point data type and adding to it a value that exceeds the six significant digits will result in a loss of precision.

See also

How values are calculated

How values are shown